package com.ruoyi.web.controller.jiugongge;

import java.util.List;
import java.util.UUID;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiugongge.domain.JiugonggeAwards;
import com.ruoyi.jiugongge.service.IJiugonggeAwardsService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.UUIDUtil;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.base.AjaxResult;

/**
 * 九宫格奖项 信息操作处理
 * 
 * @author lzy
 * @date 2019-01-21
 */
@Controller
@RequestMapping("/jiugongge/jiugonggeAwards")
public class JiugonggeAwardsController extends BaseController
{
    private String prefix = "jiugongge/jiugonggeAwards";
	
	@Autowired
	private IJiugonggeAwardsService jiugonggeAwardsService;
	
	@RequiresPermissions("jiugongge:jiugonggeAwards:view")
	@GetMapping()
	public String jiugonggeAwards()
	{
	    return prefix + "/jiugonggeAwards";
	}
	
	/**
	 * 查询九宫格奖项列表
	 */
	@RequiresPermissions("jiugongge:jiugonggeAwards:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(JiugonggeAwards jiugonggeAwards)
	{
		startPage();
        List<JiugonggeAwards> list = jiugonggeAwardsService.selectJiugonggeAwardsList(jiugonggeAwards);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出九宫格奖项列表
	 */
	@RequiresPermissions("jiugongge:jiugonggeAwards:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiugonggeAwards jiugonggeAwards)
    {
    	List<JiugonggeAwards> list = jiugonggeAwardsService.selectJiugonggeAwardsList(jiugonggeAwards);
        ExcelUtil<JiugonggeAwards> util = new ExcelUtil<JiugonggeAwards>(JiugonggeAwards.class);
        return util.exportExcel(list, "jiugonggeAwards");
    }
	
	/**
	 * 新增九宫格奖项
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存九宫格奖项
	 */
	@RequiresPermissions("jiugongge:jiugonggeAwards:add")
	@Log(title = "九宫格奖项", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(JiugonggeAwards jiugonggeAwards)
	{		
		
		jiugonggeAwards.setId(UUIDUtil.creatUUID());
		return toAjax(jiugonggeAwardsService.insertJiugonggeAwards(jiugonggeAwards));
	}

	/**
	 * 修改九宫格奖项
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		JiugonggeAwards jiugonggeAwards = jiugonggeAwardsService.selectJiugonggeAwardsById(id);
		mmap.put("jiugonggeAwards", jiugonggeAwards);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存九宫格奖项
	 */
	@RequiresPermissions("jiugongge:jiugonggeAwards:edit")
	@Log(title = "九宫格奖项", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(JiugonggeAwards jiugonggeAwards)
	{		
		return toAjax(jiugonggeAwardsService.updateJiugonggeAwards(jiugonggeAwards));
	}
	
	/**
	 * 删除九宫格奖项
	 */
	@RequiresPermissions("jiugongge:jiugonggeAwards:remove")
	@Log(title = "九宫格奖项", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jiugonggeAwardsService.deleteJiugonggeAwardsByIds(ids));
	}
	
}
